/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 17655
 * Date: 2025-03-05
 * Time: 13:58
 */
public class test1 {
    /**
     * LeetCode     121   买卖股票的最佳时机
     */

    public int maxProfit(int[] prices) {
        int n =prices.length;
        int ret = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        for(int i=0;i<n;i++){
            if(prices[i]<min){
                min = prices[i];
            }
            ret = Math.max(ret,prices[i]-min);
        }
        return ret;
    }
}
